package com.karrim.server.module;

import com.google.inject.AbstractModule;
import com.google.inject.assistedinject.FactoryModuleBuilder;
import com.karrim.server.Server;
import com.karrim.server.SocketConnectionEvent;
import com.karrim.server.SocketConnectionEventDispatcher;
import com.karrim.server.SocketConnectionEventImpl;
import com.karrim.server.annotation.Annotation.HttpPort;
import com.karrim.server.factory.GreeterFactory;
import com.karrim.server.factory.SocketConnectionEventFactory;

/**
 *
 * @author andrea.cantafio
 */
public class ServerModule extends AbstractModule {

    @Override
    protected void configure() {
        install(new FactoryModuleBuilder().implement(SocketConnectionEvent.class, SocketConnectionEventImpl.class).build(SocketConnectionEventFactory.class));
        install(new FactoryModuleBuilder().build(GreeterFactory.class));

        bind(Server.class);
        bind(SocketConnectionEventDispatcher.class);
        bindConstant().annotatedWith(HttpPort.class).to(Server.PORT_HTTP);
    }
}
